import React from 'react';

class TWIcon extends React.Component {

    state = {
        internalClassName: '',
    };

    setClassType() {

        var internalClassName = "iconfont icon-" + this.props.type;
        if (this.props.className != null)
            internalClassName += " " + this.props.className;
        this.setState({ "internalClassName": internalClassName });
    }

    componentDidMount() {
        this.setClassType();
    }

    componentWillReceiveProps = (nextProps) => {
        this.setClassType();
    }

    render() {
        return (
            <i className={this.state.internalClassName}></i>
        );
    }
}

export default TWIcon;
